// 接口正确返回结果的记录
db.bizlog.find({'status':'0'}).count()

// 结果正常的记录
db.bizlog.find({'result.normal':'0'}).count()

// 根据IP过滤
db.bizlog.find({ip:'10.170.6.46'}).count()

// 查询测试IP产生的数据
db.getCollection('bizlog').find({ip:{"$in":['127.0.0.1','218.25.32.210','139.217.19.74','59.44.43.190','59.46.22.13','59.46.22.23']}})
// 取得测试数据的SID
db.getCollection('bizlog').find({ip:{"$in":['127.0.0.1','218.25.32.210','139.217.19.74','59.44.43.190','59.46.22.13','59.46.22.23']}},{sid:1})
// 查看待删除数据的SID：
//db.getCollection('bizlog').find({ip:{"$in":['127.0.0.1','218.25.32.210','139.217.19.74','59.44.43.190','59.46.22.13','59.46.22.23']}},{sid:1}).forEach(function(myDoc) { print(myDoc.sid) })

// 删除测试数据
db.getCollection('bizlog').find({ip:{"$in":['127.0.0.1','218.25.32.210','139.217.19.74','59.44.43.190','59.46.22.13','59.46.22.23']}},{sid:1}).forEach(function(myDoc) { db.getCollection('bizlog').remove({sid:myDoc.sid}) } )

db.getCollection('bizlog').find({ip:{"$in":['127.0.0.1','218.25.32.210','139.217.19.74','59.44.43.190','59.46.22.13','59.46.22.23']}},{sid:1}).forEach(function(myDoc) { db.getCollection('ecgresult').remove({sid:myDoc.sid}) } )

// 嵌套查询：根据XML内容过滤
db.bizlog.find({'content.fs':500}).count()

// 查询包括结果反馈字段的文档
db.getCollection('ecgresult').find({feedback:{ $exists: true }})

// 查询未被采纳（反馈算法错误）的数据
db.getCollection('ecgresult').find({"feedback.content.accept_flag":"1"}).count()
// 根据开始日期过滤
db.getCollection('ecgresult').find({"feedback.content.accept_flag":"1","created":{"$gte":new Date("2019-06-30")}}).count()
// 双向过滤
db.getCollection('ecgresult').find({"feedback.content.accept_flag":"1","created":{"$gte":new Date("2019-06-28"),"$lte":new Date("2019-06-30")}}).count()

// 打印sid
db.getCollection('ecgresult').find({"feedback.content.accept_flag":"1"}).forEach(function(myDoc) {print(myDoc.sid)})


//倒排：
db.getCollection('bizlog').find({}).sort({sid:-1})

//索引
db.getCollection('bizlog').createIndex({"sid":1})
db.getCollection('ecgresult').createIndex({"sid":1})
